<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><!DOCTYPE HTML>
<%-- <%@include file="edit.jsp"%> --%>
<html>
<head>
<script type="text/javascript">
	$(function() {
		
		$("#file_upload_img").on('click',function(){
			toDeploy("jpg,png");
		});
		//添加界面的附件管理
		function toDeploy(extensions){
			showUpload({title:'上传封面'
				,options:{
					filters:{
						mime_types: [{title : "封面图片", extensions : extensions}]
					},
					multi_selection: false ,
					 init:{
						 FileUploaded:function(uploader,file,responseObject){
							 var response = responseObject.response;
							 var json = eval('(' + response + ')');
							 var data = json.data;
							 var path = data.fileUrl;
							 $("#img_id").val(data.id);  //完成后更新已上传的文件列表
							 $("#cover_url").val(path);  //封面url
							 showImg(path);
						 }
					},
					complete:function(){
						top.$ok('上传成功');
					}
				}
			});
		}
		function showImg(path){
			$("#file_img").attr("src", path); 
		}
		
		
		//父级标签
		$('#comb_pid').combotreegrid({
       		width:'100%',
        	url:'treeModel',
        	method:'post',
        	idField:'id',
        	treeField:'tagName',
        	fitColumns:true,
        	panelHeight:220,
        	columns:[[
            	{field:'tagName',title:'名称'},
        		{field:'tagNote',title:'备注 '},
        		{field:'createdDt',title:'创建时间'},
        	]]
    	});
    	$("#save_tag").on("click",function(){
    		var isValid = $('#dataform').form('enableValidation').form('validate');
    		if(!isValid){
    			return;
    		}
			toSave();
		});
		function toSave(){
			$.messager.progress({title:'系统提示',text:'数据处理中，请耐心等待...'});
			$.submit('#dataform',function(r) {
				$.messager.progress('close');
				if(r.code<0) return $alert(r.msg);
				top.$prompt('保存成功');
				top.$window.close(window,1,null);
			});
		}
	});
	
</script>
</head>
<body>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'center',border:false">
			<form id="dataform" action="edit" method="post">
				<input type="hidden" name="entity.id" value="${item.id }" />
				<input type="hidden" name="entity.enabled" value="${item.enabled }" />
				<table class="form-tbl">
					<tr class="form-tr">
						<th class="form-th">名称:</th>
						<td class="form-td">
							<input type="text" name="entity.tagName" value="${item.tagName }" class="easyui-textbox" style="width:170px;" data-options="required:true" />
						</td>
					</tr>
					<tr class="form-tr" hidden="hidden">
						<th class="form-th">父级标签:</th>
						<td class="form-td">
							<input class="easyui-combotreegrid" id="comb_pid" name="entity.pid" value="${item.pid}" />
						</td>
					</tr>
					<tr class= "form-tr">
						<td class="form-th" rowspan="2">封面</td>
						<td class="form-td" colspan="2">
							<input class="easyui-validatebox" type="hidden" id="img_id" name="entity.coverId"/>
							<input class="easyui-validatebox" type="hidden" id="cover_url" name="entity.coverUrl" value="${item.coverUrl}" />
							<img id="file_img" alt="封面" src="${item.coverUrl}" style="width: 80px;height: 50px;">
						</td>
					</tr>
					<tr class= "form-tr">
						<td class="form-td" >
	                        <input id="file_upload_img" name="file_upload_img" type="button" value="修改">
						</td>
					</tr>
					
					<tr>
						<th class="form-th">备注:</th>
						<td class="form-td">
							<input class="easyui-textbox" name="entity.tagNote" value="${item.tagNote}" data-options="multiline:true" style="height:60px;width:100%;"/>
						</td>
					</tr>
					<tr>
						<td colspan="2" style="text-align:right">
							<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" id="save_tag">保存</a>
							<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeWin();">取&nbsp;消</a>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</body>
</html>